package saucaca.CustomView;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.ViewFlipper;

public class CustomViewFlipper extends ViewFlipper {

	Paint paint = new Paint();
	Context context;

	public static final int MY_COLOR = Color.rgb(204, 51, 0);

	public CustomViewFlipper(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	protected void dispatchDraw(Canvas canvas) {
		super.dispatchDraw(canvas);
		int width = getWidth();

		float margin = 2;
		float radius = 5;
		float cx = width / 2 - ((radius + margin) * 2 * getChildCount() / 2);
		float cy = 10;

		canvas.save();

		for (int i = 0; i < getChildCount(); i++) {
			if (i == getDisplayedChild()) {
				paint.setColor(MY_COLOR);
				canvas.drawCircle(cx, cy, radius, paint);

			} else {
				paint.setColor(Color.GRAY);
				canvas.drawCircle(cx, cy, radius, paint);
			}
			cx += 2 * (radius + margin);
		}
		canvas.restore();
	}
}